import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
// import { createStyleImportPlugin } from 'vite-plugin-style-import'
// import styleImport from 'vite-plugin-style-import'
import postCssPxToRem from 'postcss-pxtorem'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    react(),
    // styleImport({
    //   libs: [
    //     {
    //       libraryName: 'zarm',
    //       esModule: true,
    //       resolveStyle: (name) => {
    //         return `zarm/es/${name}/style/css`
    //       },
    //     },
    //   ],
    // })
  ],
  server: {
    port: 8081,
       // proxy: {
    //   '/api': {
    //     target: 'xxxxxxx',
    //     changeOrigin: true,
    //     rewrite: path => path.replace(/^\/api/, '')
    //   }
    // }
  },
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'),
      'utils':path.resolve(__dirname, '/src/utils')
    }
  },
  css: {
    modules: {
      localsConvention: "dashesOnly"
    },
    preprocessorOptions: {
      less: {
        // 支持内联 javascript
        javascriptEnabled: true
      }
    },
    postcss: {
      plugins: [
        postCssPxToRem({
          rootValue: 37.5,
          propList: ['*'],
          selectorBlackList: ['.norem'] // .norem-xxxx
        })
      ]
    }
  }
})